<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    function Dog(name) {
        this.name = name
    }
    var dog = new Dog('小狗');
    // 自己写的new
    function myDog(fn, ...args) {
        const obj = Object.create(fn.prototype)
        const res = fn.apply(obj, args)
        return res instanceof Object ? res : obj;
    }
    var newDog = new myDog(Dog, "小狗");
    console.log(newDog)
</script>

</html>